import api from './api';
import { Tenant, PaginatedResponse } from '../types';

export const tenantService = {
  getTenants: async (params?: { skip?: number; limit?: number }): Promise<PaginatedResponse<Tenant>> => {
    const response = await api.get<PaginatedResponse<Tenant>>('/Tenants', { params });
    return response.data;
  },

  getTenant: async (id: number): Promise<Tenant> => {
    const response = await api.get<Tenant>(`/Tenants/${id}`);
    return response.data;
  },

  createTenant: async (data: Partial<Tenant>): Promise<Tenant> => {
    const response = await api.post<Tenant>('/Tenants', data);
    return response.data;
  },

  updateTenant: async (id: number, data: Partial<Tenant>): Promise<Tenant> => {
    const response = await api.put<Tenant>(`/Tenants/${id}`, data);
    return response.data;
  },

  deleteTenant: async (id: number): Promise<void> => {
    await api.delete(`/Tenants/${id}`);
  },
};

export default tenantService;
